cloth(dresses, dress1, darkBlue, long, summer, pois,overall).
cloth(shirt, shirt1, darkBlue, long, summer, pois,top).
cloth(jackets, jackets1, darkBlue, short, summer, pois,coat).
cloth(sportshoes, sport2, darkBlue, long, summer, pois,footwear).
cloth(blouses, blouses2, darkBlue, short, summer, pois,top).
cloth(sweater, sweater2, darkBlue, long, summer, pois,top).

first_selection(Category, Name, Color, Length, Season,Extra,Position,[A|B],[C|D],[neg|F]):-
list(C),cloth(Category,Name,Color,Length,Season,Extra,Position),member(A,C),
first_selection(Category, Name, Color, Length, Season,Extra,Position,B,D,F).

first_selection(Category, Name, Color, Length, Season,Extra,Position,[A|B],[C|D],[pos|F]):-
list(C),cloth(Category,Name,Color,Length,Season,Extra,Position),not(member(A,C)),
first_selection(Category, Name, Color, Length, Season,Extra,Position,B,D,F).

first_selection(Category, Name, Color, Length, Season,Extra,Position,[A|B],[C|D],[neg|F]):-
color_list(X,Y),A==X ,cloth(Category,Name,Color,Length,Season,Extra,Position),member(A,C),
first_selection(Category, Name, Color, Length, Season,Extra,Position,B,D,F).

first_selection(Category, Name, Color, Length, Season,Extra,Position,[A|B],[C|D],[pos|F]):-
color_list(X,Y),A==X ,cloth(Category,Name,Color,Length,Season,Extra,Position),not(member(A,C)),
first_selection(Category, Name, Color, Length, Season,Extra,Position,B,D,F).

first_selection(Category, Name, Color, Length, Season,Extra,Position,[A|B],[C|D],[neg|F]):-
cloth(Category,Name,Color,Length,Season,Extra,Position),A=C, 
first_selection(Category, Name, Color, Length, Season,Extra,Position,B,D,F).


first_selection(Category, Name, Color,Length, Season,Extra,Position,[A|B],[C|D],[pos|F]):-
cloth(Category,Name,Color,Length,Season,Extra,Position),A\=C,
first_selection(Category, Name, Color, Length, Season,Extra,Position,B,D,F).

first_selection(Category, Name, Color, Length, Season,Extra,Position,[],[],[]).

if_selection([], Name, Color, Length, Season,Extra,Position,[],[],[]).
if_selection([H|T], Name, Color, Length, Season,Extra,Position,[I|J],[K|L],[M|N]):- 
first_selection(H, Name, Color, Length, Season,Extra,Position,[I],[K],[M]), write(J),write(L),write(N),
Length==Length2,
if_selection(T, Name1, Color1, Length1, Season1,Extra1,Position1,J,L,N).



mmproduct(M,N,R):- findall([X,Y],(member(X,M),member(Y,N)),R).

call_exclude(Cat1,Attr1,Val1,Pol1,Cat2,Attr2,Val2,Pol2):- exclude(Cat1,Attr1,Val1,Pol1,Cat2,Attr2,Val2,Pol2,R),assertz(R).
call_exclude(Cat1,Attr1,Val1,Pol1,Cat2,Attr2,Val2,Pol2):- else_esclude(Cat1,Attr1,Val1,Pol1,Cat2,Attr2,Val2,Pol2,R),assertz(R).

else_esclude(Cat1,Attr1,Val1,Pol1,Cat2,Attr2,Val2,Pol2,R):- exclude(Cat1,Attr1,Val1,Pol1,Cat2,Attr2,Val2,Pol2,R).

exclude(Cat1,Attr1,Val1,Pol1,Cat2,Attr2,Val2,Pol2,R):-bagof(cloth(Cat1,Name,Color,Length,Season,Extra,Position),
first_selection(Cat1,Name,Color,Length,Season,Extra,Position,[Attr1],[Val1],[Pol1]),L1),
bagof(cloth(Cat2,Name,Color,Length,Season,Extra,Position),
first_selection(Cat2, Name, Color, Length, Season,Extra,Position,[Attr2],[Val2],[Pol2]),L2),
mmproduct(L1,L2,R).





